window.addEventListener('DOMContentLoaded', function () {
  // 必应搜索功能
  function search() {
    if (document.getElementById("search-input").value != "") {
      window.location.href = "https://cn.bing.com/search?q=" + document.getElementById("search-input").value;
      document.getElementById("search-input").value = "";
    }
    return false;
  }
})

// 不能添加onload，否则搜索框显示不出来/
var searchNav = document.querySelector('footer').querySelector('.search-nav');
var searchBox = document.querySelector('.search-container');
var searchIcon = document.querySelector('.searchIcon');
var flag = true;
// console.log(searchBox);
searchNav.addEventListener('click', function () {
  if (flag == true) {
    searchBox.style.display = 'block';
    flag = false;
    searchNav.innerHTML = '隐藏';
    searchNav.style.color = '#e94256';
    searchIcon.style.background = 'url(../icons/searchIconActive.svg)';
    // console.log(flag);
  } else {
    searchBox.style.display = 'none';
    flag = true;
    // console.log(flag);
    searchNav.innerHTML = '搜索';
    searchNav.style.color = '#111';
    searchIcon.style.background = 'url(../icons/searchIcon.svg)';
  }
})